<template>
    <div>
        <el-table
            ref="currencyTable"
            :data="tableData"
            stripe
            style="width: 100%"
            @selection-change="getSelectVal"
            v-loading="loading"
        >
            <el-table-column
                type="selection"
                width="55"
                align="center"
            ></el-table-column>
            <el-table-column
                type="index"
                label="序号"
                width="55"
                align="center"
            />
            <el-table-column prop="code" label="编码"></el-table-column>
            <el-table-column prop="name" label="名称"></el-table-column>
            <el-table-column
                prop="directRateAccuracy"
                label="直接汇率精度"
            ></el-table-column>
            <el-table-column
                prop="indirectRateAccuracy"
                label="间接汇率精度"
            ></el-table-column>
            <el-table-column prop="isSystem" label="是否系统预设">
                <template slot-scope="scope">
                    <el-tag v-if="scope.row.isSystem">是</el-tag>
                    <el-tag v-else-if="!scope.row.isSystem">否</el-tag>
                    <span v-else>--</span>
                </template>
            </el-table-column>
            <el-table-column prop="userId" label="录入人"></el-table-column>
            <el-table-column prop="changeId" label="修改人"></el-table-column>
            <el-table-column prop="describe" label="描述"></el-table-column>
        </el-table>
        <el-pagination
            class="pagination mt10"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="page"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="limit"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            background
        >
        </el-pagination>
    </div>
</template>

<script>
import { getExchangeTypeData } from "@/api/base/data";
export default {
    data() {
        return {
            tableData: [],
            page: 1, //当前页
            limit: 10, //每页条数
            total: 0,
            loading: false,
        };
    },
    methods: {
        //分页器size
        handleSizeChange(val) {
            this.limit = val;
            this.getDataList();
        },
        //分页器当前页
        handleCurrentChange(val) {
            this.page = val;
            this.getDataList();
        },
        getSelectVal(val) {
            if (val.length) {
                this.$emit("update:visible", false);
                this.$emit("getSelectVal", val);
            }
        },
        getDataList() {
            this.loading = true;
            let params = {
                page: this.page,
                limit: this.limit,
            };
            getExchangeTypeData(params).then((res) => {
                this.tableData = res.rows;
                this.total = res.total;
                this.loading = false;
            });
        },
    },
    mounted() {
        this.getDataList();
    },
};
</script>

<style></style>
